<table>
  <tr>
    <th>Day</th>
    <th>Owner</th>
    <th>Name</th>
    <th>Duration</th>
    <th>Type</th>
    <th>Approved</th>
    <% if @current_user.administrator %>
      <th>Edit</th>

      <% if defined?(show_approve) %>
        <th>Approve</th>
      <% end %>
    <% end %>
  </tr>

<% events.each_with_index do |event, idx| %>
  <tr>

    <%# Only display name of day once %>
    <% if idx == 0 || events[idx - 1].begin_date != event.begin_date %>
      <td><%= event.begin_date.strftime("%A") %></td>
    <% else %>
      <td><center>&bull</center></td>
    <% end %>

    <td><%= link_to event.owner.username, event.owner %></td>
    <td><%= link_to event.name, event %></td>

    <% if event.duration_type == Event::MULTI_DAY %>
      <td><%= pluralize(event.duration, 'days')%></td>
    <% else %>
      <td><%= Event::DURATION_NAMES[event.duration_type] %></td>
    <% end %>

    <td><%= Event::TYPE_NAMES[event.event_type] %></td>
    <td><%  display_true_false_field(event.approved) %></td>
    <% if @current_user.administrator %>
      <td><%= link_to 'Edit', edit_event_path(event) %></td>
      <% if defined?(show_approve) %>
        <td><%= link_to 'Approve', approve_event_path(event) %></td>
      <% end %>
    <% end %>
  </tr>
<% end %>
</table>

